<template>
	<slot
		:controller="controller"
		:store="store"
		:model="model"
		:classNames="classNames"
	>
		<AppExpBar :class="classNames" :id="controlID">
			<template #default>
				<slot
					name="Sys_roleUsr0309252920Tree"
					:controller="controller"
					:store="store"
					:model="model"
					:actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }"
				>
					<Sys_roleUsr0309252920Tree
						:selectFirstDefault="true"
						:openView="store.openView"
						:newView="store.newView"
						name="treeexpbar_tree"
						v-bind="model.ctrlParams.Sys_roletreeexpbar_tree"
						:context="store.context"
						:viewParams="store.viewParams"
						:closeView="store.closeView"
						:pLoadingHelper="store.loadingHelper"
						:pViewCtx="store.viewCtx"
						@ctrl-init="(name:string, ability:any) => { handleCtrlInit(controller, name, ability) }"
						@ctrl-action="(name:string, action:any, data:any) => { handleCtrlAction(controller, name, action, data) }"
						@ctrl-destroy="(name:string, data:any) => { handleCtrlDestroy(controller, name, data) }"
					/>
				</slot>
			</template>
		</AppExpBar>
	</slot>
</template>
<script setup lang="ts">
// 基于template/src/widgets/{{appEntities}}/{{ctrls@TREEEXPBAR}}-tree-exp-bar/{{spinalCase ctrl.codeName}}-tree-exp-bar-base.vue.hbs生成
import Sys_roleUsr0309252920Tree from '@widgets/sys-role/usr-0309252920-tree/usr-0309252920-tree.vue';
import { AppExpBar } from '@components/widgets/exp-bar';
import {
	useProps,
	useBasic,
	useAction,
	useController,
} from './usr-0309683501-m-pickup-view-2-treeexpbar-tree-exp-bar-hook';
import {
	TreeExpBarActionType,
	ITreeExpBarAbility,
	ITreeExpBarStore,
	IParam,
} from '@/core';

// 输入参数
const props = defineProps(useProps());

// 基础数据
const {
	model,
	controlID,
	getClassNames,
	useNavParamsBind,
	useEventBind,
	handleCtrlDestroy,
	handleCtrlInit,
	handleCtrlAction,
	handleToolbarItemClick,
	handleQuickSearch,
} = useBasic(props);

const emit = defineEmits<{
	(
		event: 'ctrl-action',
		name: string,
		action: TreeExpBarActionType,
		data: IParam[]
	): void;
	(event: 'ctrl-init', name: string, data: ITreeExpBarAbility): void;
	(event: 'ctrl-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
const classNames = computed(() => {
	return getClassNames(props);
});

const controller = useController(props, evt, { controlID });

useNavParamsBind(controller, props);

const store: ITreeExpBarStore = controller.getStore();

onMounted(() => {
	controller.ctrlMounted();
});

onUnmounted(() => {
	controller.ctrlDestroy();
});
</script>
